package com.zhiwei.msf.gateway.service.impl;

import com.zhiwei.msf.gateway.dao.entity.RoleInfo;
import com.zhiwei.msf.gateway.dao.mapper.extmapper.ExtRoleInfoMapper;
import com.zhiwei.msf.gateway.service.RoleInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.util.Collections;
import java.util.List;

/**
 * function 角色信息服务
 * author zhiwei.yang
 * time 2020-2-27-11:00
 */
@Slf4j
@Service
public class RoleInfoServiceImpl implements RoleInfoService {

    @Autowired
    private ExtRoleInfoMapper extRoleInfoMapper;

    @Override
    public List<RoleInfo> queryRoleInfosByUserId(String userId) {
        if (StringUtils.isEmpty(userId)) {
            return Collections.emptyList();
        }
        List<RoleInfo> roleInfoList = extRoleInfoMapper.queryRoleInfoByUserId(userId);
        log.info("查询用户角色信息userId:[{}], roleInfoList ==> {}", userId, roleInfoList);
        return CollectionUtils.isEmpty(roleInfoList) ? Collections.emptyList() : roleInfoList;
    }
}